/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023.
 * Description: report when scsi IO fail
 * Author: Pang LiYuan
 * Create: 2023-09-12
 */
#include <linux/rtos_storage_hooks.h>
#include <linux/blkdev.h>

static ATOMIC_NOTIFIER_HEAD(scsi_err_notifier_list);

int rtos_scsi_err_notifier_list_register(struct notifier_block *nb_ptr)
{
	return atomic_notifier_chain_register(&scsi_err_notifier_list, nb_ptr);
}
EXPORT_SYMBOL(rtos_scsi_err_notifier_list_register);

int rtos_scsi_err_notifier_list_unregister(struct notifier_block *nb_ptr)
{
	return atomic_notifier_chain_unregister(&scsi_err_notifier_list, nb_ptr);
}
EXPORT_SYMBOL(rtos_scsi_err_notifier_list_unregister);

void scsi_err_notifier(struct request *req)
{
	atomic_notifier_call_chain(&scsi_err_notifier_list, 0, req->rq_disk->disk_name);
}
